home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / kintegerline.h.z / kintegerline.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  3.5 KB  |  124 lines

  1. /**********************************************************************
  2. **
  3. ** $Id: kintegerline.h,v 1.4 1998/06/01 08:42:44 kalle Exp $
  4. **
  5. ** Definition of KIntegerLine
  6. **
  7. ** Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de>
  8. **
  9. ** This library is free software; you can redistribute it and/or
  10. ** modify it under the terms of the GNU Library General Public
  11. ** License as published by the Free Software Foundation; either
  12. ** version 2 of the License, or (at your option) any later version.
  13. **
  14. ** This library is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. ** Library General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU Library General Public
  20. ** License along with this library; if not, write to the Free
  21. ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22. **
  23. *****************************************************************************/
  24.  
  25. #ifndef KINTEGERLINE_H
  26. #define KINTEGERLINE_H
  27.  
  28. #include "krestrictedline.h"
  29.  
  30. /** Enum for the possible types of Editlines
  31.     */
  32. enum KEditLineType{
  33.   KEditTypeOct =  8,
  34.   KEditTypeDec = 10,
  35.   KEditTypeHex = 16
  36. };
  37.  
  38. /** IntegerEditline: Editline for Integers. Only octal, decimal or
  39.     hexadecimal characters are valid input characters for this sort 
  40.     of edit lines. 
  41.     A few special keys are supported by this class:
  42.     <ul>
  43.     <li>The up-arrow increments the contents by 1, 
  44.     <li>the down-arrow decrements the contents by 1,
  45.     <li>Page-Up increments by 8, 10 or 16 (depending on the EditLineType),
  46.     <li>Page-Down decrements by 8, 10 or 16 (depending on the EditLinetype)
  47.     </ul>
  48.  
  49.     @author Michael Wiedmann <mw@miwie.in-berlin.de>
  50.     @version 0.0.1
  51.   */
  52. class KIntegerLine : public KRestrictedLine
  53. {
  54.   Q_OBJECT
  55.   
  56. public:
  57.   /**@name methods */
  58.   //@{
  59.   /** Default - empty - constructor
  60.     */
  61.   KIntegerLine();
  62.     
  63.   /** Contructor: This constructor takes three - optional - arguments.
  64.       The first two parameters are simply passed to KRestrictedLine.
  65.       @param parent   pointer to the parent widget
  66.       @param name     pointer to the name of this widget
  67.       @param t        type of this integer line (defaults to KEditTypeDec)
  68.   */
  69.   KIntegerLine( QWidget *parent=0, 
  70.                 const char *name=0, 
  71.                 KEditLineType t=KEditTypeDec);
  72.  
  73.   /// Destructor
  74.   ~KIntegerLine();
  75.  
  76.   /// Get the type of this Line
  77.   KEditLineType getType();
  78.  
  79.   /// Get the current value in the lined
  80.   int value( void );
  81.   
  82.   /// Set the current value in the lined
  83.   void setValue( int value );
  84.   //@}
  85.  
  86. signals:
  87.   // emitted whenever the value changes
  88.   void valueChanged( int );
  89.  
  90. protected:
  91.   /** Key press event handler. 
  92.       Handles the following special keys:
  93.       <UL>
  94.       <LI>Key_Up:    Increments contents of line by 1
  95.       <LI>Key_Prior: Increments contents of line by 8, 10 or 16
  96.       <LI>Key_Down:  Decrements contents of line by 1
  97.       <LI>Key_Next:  Decrements contents of line by 8, 10 or 16
  98.       </UL>
  99.   */
  100.   void    keyPressEvent( QKeyEvent *e );
  101.  
  102. private slots:
  103.   void internalValueChanged();
  104.  
  105. private:
  106.   /// type of this line
  107.   KEditLineType lineType;
  108.  
  109.   /// get value based on radix of this line
  110.   int getValue(QString &s);
  111.     
  112.   /// put value based on radix of this line
  113.   void putValue(QString &s, int val);  
  114.  
  115.   /// increment value based on radix of this line
  116.   void incValue(QString &s, int val);
  117.  
  118.   /// decrement value based on radix of this line
  119.   void decValue(QString &s, int val);
  120. };
  121.  
  122. #endif // 
  123.  
  124.